{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% set active_menu = 'system' %}
{% block meta_title %}{% trans 'BoxBilling license' %}{% endblock %}

{% block breadcrumbs %}
    <ul>
        <li class="firstB"><a href="{{ '/'|alink }}">{% trans 'Home' %}</a></li>
        <li><a href="{{ 'system'|alink }}">{% trans 'Settings' %}</a></li>
        <li class="lastB">{% trans 'BoxBilling license' %}</li>
    </ul>
{% endblock %}


{% block content %}

    <div class="widget">
        <div class="head">
            <h5>{% trans 'BoxBilling license' %}</h5>
        </div>

        <div class="body">
            <h2>{% trans '1. Configure API' %}</h2>
        </div>
        
        {% set params = admin.serviceboxbillinglicense_config_get %}
        <form method="post" action="{{ 'api/admin/serviceboxbillinglicense/config_update'|link }}class="mainForm api-form" data-api-msg="{% trans 'Configuration updated' %}">
            <fieldset>
                <div class="rowElem noborder">
                    <label class="topLabel"><a href="http://www.boxbilling.com/login" target="_blank">Login to BoxBilling</a> and get your API key at <a href="http://www.boxbilling.com/me" target="_blank">profile page</a>.</label>
                    <div class="formBottom">
                        <input type="password" name="api_key" value="{{params.api_key}}" required="required" placeholder="Example: xsd4zzydzvndcwdkvviaqfyykjOardxi" style="width: 300px"/>
                        <input type="button" value="2. {% trans 'Test connection' %}" class="greyishBtn submitForm" id="testconnection"/>
                        <input type="submit" value="1. {% trans 'Update API key' %}" class="greyishBtn submitForm" />
                    </div>
                    <div class="fix"></div>
                </div>
            </fieldset>
        </form>
        
        <div class="body">
            <h2>{% trans '2. Become partner' %}</h2>
            <p><a href="{{ 'api/admin/serviceboxbillinglicense/become_partner'|link }}" class="btnIconLeft mr10 mt10 api-link" data-api-jsonp="onAfterBecomePartner"><span>Click here to become partner</span></a></p>
            <p><a href="http://www.boxbilling.com/partner" target="_blank">Go to partnership program page</a> for more information.</p>
        </div>
        
        <div class="body list arrowBlue">
            <h2>{% trans '3. Create license product' %}</h2>
            <p><a href="{{'product'|alink({'type' : 'boxbillinglicense', 'title' : 'BoxBilling License' })}}#tab-new" target="_blank">Create BoxBilling license product</a></p>
            <p>You can sell licenses for any price you want or even give it for free. All money collected from your clients stays for you.</p>
            <p>BoxBilling will start charging you only for active licenses after 14 days. This gives you ability to make revenue before you even spend money.</p>
            <p>Thats it. Remember the more you sell the lower the price you receive.</p>
        </div>
    </div>
        
{% endblock %}

{% block js %}
{% autoescape true js %}
<script type="text/javascript">
    
function onAfterBecomePartner() {
    bb.msg('You have successfully become BoxBilling partner.');
}

$(function() {
    $('#testconnection').click(function(){
        bb.post('admin/serviceboxbillinglicense/test_connection', null, function(result){
            bb.msg('Successfully connected to BoxBilling API');
        });
        return false;
    });
});
</script>
{% endautoescape %}
{% endblock %}